import axios from "axios";
import qs from "qs";

let baseURL = '';
if (process.env.NODE_ENV === 'production') {
    baseURL = ''; // 生产环境
} else if (process.env.NODE_ENV === 'development') {
    baseURL = ''; // 开发环境
}

// 请求拦截器
axios.interceptors.request.use((req) => {
    return req;
})
axios.interceptors.response.use((res) => {
    return res;
})

export const get = (url, params = {}) => {
    return axios.get(baseURL + url, {
        params
    })
}

export const post = (url, params = {}, isFile = false) => {
    let data = null;
    if (isFile) {
        data = new FormData();
        for (let key in params) {
            data.append(key, params[key]);
        }
    } else {
        data = qs.stringfy(params);
    }
    return axios.post(baseURL + url, data)
}